package stz.flash.option.flashlight;

import stz.flash.option.PersistentData;
import util.DjObservable;


/**
 * 옵저버로 등록되어 있는 클래스
 * @param BacklightFieldChangeListener 
 * 
 * 
 * Backlight는 특별히 FlashTimer에서 컨트롤 하지 않기때문에
 * 이곳에서 직접 notify하여야 한다.
 */
public class BacklightOption extends DjObservable {

	private static BacklightOption instance = new BacklightOption();

	private static boolean latestBacklightState;
	
	private PersistentData data = PersistentData.getPersistentDatabase();
	
	private BacklightOption() {
	}

	
	public static BacklightOption getIns() {
		return instance;
	}
	
	
	public void setStartupBacklightState(boolean startupBacklightOn) {
		data.setStartupBacklightState(startupBacklightOn);
		setLatestBacklightStateAndNotify(startupBacklightOn);
	}
	public boolean isStartupBacklightState() {
		return data.isStartupBacklightState();
	}
	
	
	public void updateLatestBacklightStateWithStartupSet(){
		setLatestBacklightStateAndNotify(isStartupBacklightState());
	}
	
	
	public void setLatestBacklightStateAndNotify(boolean backlightState) {
		latestBacklightState = backlightState;
		notifyObservers();
	}
	public boolean isLatestBacklightState() {
		return latestBacklightState;
	}
}